import MiniCart from './main.vue';
import Vue from 'vue'

let instance;

const MiniCartConstructor = Vue.extend(MiniCart);

const initInstance = () => {
    instance = new MiniCartConstructor({
        el: document.createElement('div')
    });

    // instance.callback = defaultCallback;
};

MiniCart.show = (a) => {
    if (!instance) {
        initInstance();
    }
    instance.age = a;
    console.log(a);
    document.body.appendChild(instance.$el);
};

const install = function (Vue) {
    Vue.component(MiniCart.name, MiniCart);
    Vue.prototype.$minicart = MiniCart;
};

if (typeof window !== 'undefined' && window.Vue) {
    install(window.Vue);
}


export default {
    version: '0.0.1',
    install,
    MiniCart
};